﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace mds.WeixinApiService
{
    public class WeixinHelper
    {
        /// <summary>
        /// 获取web通讯流中的xml的文本内容
        /// 获取失败返回空字符串
        /// </summary>
        /// <returns></returns>
        public string GetXMLByWebPost()
        {
            string str = "";
            var request=System.Web.HttpContext.Current.Request;
            try
            {
                if (request.HttpMethod.ToLower() == "post")
                {
                    Stream s = request.InputStream;
                    byte[] byteData = new byte[s.Length];
                    s.Read(byteData, 0, (int)s.Length);
                    str = Encoding.UTF8.GetString(byteData);
                }
            }
            catch { }
            return str;
        }
    }
}
